package vek.GUI.MapView;

import javax.swing.*;
import java.awt.Graphics;
import javax.swing.JPanel;
import java.awt.Image;
import java.awt.Dimension;

/**
 * This JPanel shows the background image
 * @author Christian, Michal og Jakob (Hold 1, gruppe 2)
 */
public class Background extends JPanel{
    
    private Image backgroundImage;
    private int width;
    private int height;
    
    public Background(Image img, Dimension size)
    {
        backgroundImage = img;
        width = backgroundImage.getWidth(null);
        height = backgroundImage.getHeight(null);
        
        setPreferredSize(size);
    }
    
    /**
     * draws this component using the background image.
     * @param g the graphics to be drawn in this component
     */
    @Override
    public void paintComponent(Graphics g)
    {
        g.drawImage(backgroundImage, 0,0, width, height, null); 
    }
    
    /**
     * gets the background image
     * @return the background image
     */
    
    public Image getImage()
    {
        return backgroundImage;
    }

}
